package com.heima.wemedia.controller;

import com.heima.model.comment.dto.CommentConfigDto;
import com.heima.model.comment.pojos.CommentLike;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmCommentAndRepayDto;
import com.heima.model.wemedia.dtos.WmCommentDto;
import com.heima.wemedia.service.WmCommentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Cvalence
 * @version 1.0
 * @project leadnews-project
 * @date 2024/1/25 09:29:05
 */

@RestController
@RequestMapping("/api/v1/comment/manage")
@Slf4j
public class WmCommentController {


    @Autowired
    private WmCommentService wmCommentService;

    /**
     * @return {@link ResponseResult}
     * 评论管理查询
     */
    @PostMapping("/find_news_comments")
    public PageResponseResult commentManagementQueries(@RequestBody WmCommentDto wmCommentDto) {
        return wmCommentService.commentManagementQueries(wmCommentDto);
    }

    @PostMapping("/update_comment_status")
    public ResponseResult updateCommentStatus(@RequestBody CommentConfigDto wmUpdateStatusDto) {
        return wmCommentService.updateCommentStatus(wmUpdateStatusDto);
    }

    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmCommentAndRepayDto wmCommentAndRepayDto) {
        return wmCommentService.list(wmCommentAndRepayDto);
    }

    /**
     * 删除评论回复功能
     * @param commentRepayId
     * @return
     */
    @DeleteMapping("/del_comment_repay/{commentRepayId}")
    public ResponseResult delCommentRepay(@PathVariable String commentRepayId){
        return wmCommentService.delCommentRepay(commentRepayId);
    }

    @DeleteMapping("/del_comment/{commentId}")
    public ResponseResult delComment(@PathVariable("commentId") String commentId) {
        return wmCommentService.delComment(commentId);
    }

    /**
     * 作者点赞操作
     *
     * @param commentLike 评论喜欢
     * @return {@link ResponseResult}
     */
    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentLike commentLike) {
        return wmCommentService.like(commentLike);
    }


}